package com.ailesson.order.config;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WxPayMpConfig {

    @Autowired
    private WxPayProperties wxPayProperties;

    @Bean
    public WxPayService wxPayService(){
        WxPayService payService = new WxPayServiceImpl();
        WxPayConfig config = new WxPayConfig();
        config.setAppId(wxPayProperties.getAppId());
        config.setMchId(wxPayProperties.getMchId());
        config.setMchKey(wxPayProperties.getMchKey());
        config.setTradeType("JSAPI");
        config.setNotifyUrl(wxPayProperties.getNotifyUrl());
        payService.setConfig(config);
        return payService;
    }

}
